// .txt

beginzonescript;

variables;

short crime_tolerance = 5;
short last_abil;
short i;
short cutscene = 0;

body;

beginstate INIT_STATE;
	toggle_quest(2,3);

	set_name(11,"Gevik");
	if (gf(2,4) > 0)
		erase_char(11);

	add_range_to_group(12,14,1);
	set_aggression(1001,6);
	
	set_aggression(17,10);
	set_aggression(18,10);

	set_aggression(1001,6);
	
	add_range_to_group(19,22,2);

	set_name(23,"Captain Valenta");
	set_name(24,"Barcott");
	set_name(25,"Keeper Cooper");
	set_name(26,"Twixx");
	set_name(27,"Lazzaria");
	set_name(28,"Mind Shimp");
	set_name(29,"Minallah Soldier");
	set_name(30,"Minallah Soldier");
	set_name(31,"Minallah Soldier");
	set_name(32,"Minallah Soldier");
	set_name(33,"Minallah Soldier");
	set_name(34,"Minallah Soldier");
	set_name(35,"Minallah Soldier");
	set_name(36,"Minallah Soldier");
	set_name(37,"Minallah Soldier");

	set_name(42,"Ol' Pinchy");
	set_level(42,25);
	
	set_name(45,"Farad");
	set_name(46,"Thahd Bodyguard");

	set_name(47,"Servile Assistant");
	set_name(48,"Servile Assistant");
	
	if (gf(1,7) > 0) {
		erase_char(8);
		erase_char(9);
		erase_char(10);
		}

	last_abil = get_current_tick();
	
	set_crime_tolerance(crime_tolerance);

	if (gf(100,11) > 0) {
		print_str_color("Word of your infamy has gotten here before you. You are forever marked",3);
		print_str_color("  as a foe of the Shapers.",3);
		sf(1,6,1);
		}

	if (get_sdf(1,6) > 0) {
		make_zone_hostile();
		}
		else {
			print_str_color("This is a friendly settlement. You are able to rest.",2);
			revive_party();
			}	

	break;

beginstate EXIT_STATE;

break;

beginstate START_STATE;
	// clear zone?
	//if ((zone_clear(ME) == FALSE) && (get_flag(,) > 0)) {
		//print_str_color("",2);
		//clear_zone(ME);	
		//}
		
	if ((get_crime_level() >= crime_tolerance) && (get_sdf(1,6) == 0)) {
		make_zone_hostile();
		set_flag(1,6,1);
		}
	if ((gf(1,6) > 0) && (gf(2,1) < 2)) 
		begin_talk_mode(290);

	if (gf(1,6) == 0) {
	if ((gf(2,1) == 0) && (get_ran(1,0,100) < 18))
		give_char_text_bubble(23,"Go find Shaper Rawal.");
	if ((gf(2,1) == 0) && (get_ran(1,0,100) < 18))
		give_char_text_bubble(23,"The Spire is northwest.");
	if (get_ran(1,0,100) < 10)
		give_char_text_bubble(23,"What? Another rogue?");
	if (get_ran(1,0,100) < 10)
		give_char_text_bubble(23,"Not enough guards.");
	if (get_ran(1,0,100) < 10)
		give_char_text_bubble(23,"More work to do.");
	if (get_ran(1,0,100) < 10)
		give_char_text_bubble(24,"Come get some warmth.");
	if (get_ran(1,0,100) < 10)
		give_char_text_bubble(24,"Want to buy something?");
	if (get_ran(1,0,100) < 10)
		give_char_text_bubble(24,"This is a shop. Really.");
	if (get_ran(1,0,100) < 10)
		give_char_text_bubble(25,"Keep warm.");
	if (get_ran(1,0,100) < 10)
		give_char_text_bubble(25,"Don't touch that!");
	if (get_ran(1,0,100) < 10)
		give_char_text_bubble(25,"It will be all right.");
	if (get_ran(1,0,100) < 10)
		give_char_text_bubble(25,"Stay calm.");
	if (get_ran(1,0,100) < 10)
		give_char_text_bubble(27,"I make Shaper crafts.");
	if (get_ran(1,0,100) < 10)
		give_char_text_bubble(27,"Please be careful.");
	if (get_ran(1,0,100) < 10)
		give_char_text_bubble(27,"Don't break anything.");
	if (get_ran(1,0,100) < 10)
		give_char_text_bubble(28,"Recalling.");
	if (get_ran(1,0,100) < 10)
		give_char_text_bubble(28,"Searching.");
	if (get_ran(1,0,100) < 10)
		give_char_text_bubble(28,"Thinking.");
	if (get_ran(1,0,100) < 10)
		give_char_text_bubble(28,"State your need.");
	if (get_ran(1,0,100) < 10)
		give_char_text_bubble(29 + get_ran(1,0,3),"Brrrr.");
	if (get_ran(1,0,100) < 10)
		give_char_text_bubble(29 + get_ran(1,0,3),"Curse this wind.");
	if (get_ran(1,0,100) < 10)
		give_char_text_bubble(29 + get_ran(1,0,3),"What was that?");
	if (get_ran(1,0,100) < 10)
		give_char_text_bubble(38 + get_ran(1,0,3),"Aaaahhh!");
	if (get_ran(1,0,100) < 10)
		give_char_text_bubble(38 + get_ran(1,0,3),"I'm hungry.");
	if (get_ran(1,0,100) < 10)
		give_char_text_bubble(38 + get_ran(1,0,3),"I'm scared!");
	if (get_ran(1,0,100) < 10)
		give_char_text_bubble(38 + get_ran(1,0,3),"Ahhhh! A rogue!");

	if (get_ran(1,0,100) < 10)
		give_char_text_bubble(45,"When will he see me?");
	if (get_ran(1,0,100) < 10)
		give_char_text_bubble(45,"So cold up here.");
	if (get_ran(1,0,100) < 10)
		give_char_text_bubble(45,"Cursed Foundry.");
	}

	//if (((is_combat()) && (tick_difference(last_abil,get_current_tick()) > 0)) || (((is_group()) && (tick_difference(last_abil,get_current_tick()) > 5))) {
	//	last_abil = get_current_tick();
	//	}
	
	if ((gf(1,7) > 0) && (gf(1,7) < 4)) {
		if (cutscene == 1) {
			cutscene = 2;
			give_char_text_bubble(8,"Rogues must die.");
			give_char_text_bubble(10,"Sssss!");
			begin_talk_mode(10);
			}
		else if (cutscene == 2) {
			give_char_text_bubble(8,"Rogues must die.");
			move_to_loc(0,41,28);
			move_to_loc(1,40,27);
			move_to_loc(2,42,27);
			move_to_loc(3,39,26);
			move_to_loc(4,41,26);
			move_to_loc(5,43,26);
			move_to_loc(6,40,25);
			move_to_loc(7,42,25);
			shift_view_to_char(pc_num());
			
			
			if (cutscene_can_proceed()) {
				give_char_text_bubble(9,"It's not rogue yet!");
				give_char_text_bubble(10,"");
				set_facing(1000,3);
				shift_view_to_char(pc_num());
				cutscene = 3;
				}
			}
		else if (cutscene == 3) {
			give_char_text_bubble(8,"");
			give_char_text_bubble(10,"Hssssss!");
			cutscene = 4;
			}
		else if (cutscene == 4) {
			cutscene = 5;
			}
		else if (cutscene == 5) {
			cutscene = 6;
			give_char_text_bubble(9,"");
			give_char_text_bubble(10,"");
			sf(1,7,2);
			begin_talk_mode(15);
			}
		else if (cutscene == 6) {
			cutscene = 7;
			if (gf(1,7) == 3)
				cutscene = 13;
			}
		else if (cutscene == 7) {
			run_a_char_animation(8,5,1,50);	
			cutscene = 8;
			play_sound(238);
			run_sparkles_on_char(8,5,12,1);
			}
		else if (cutscene == 8) {
			cutscene = 9;
			run_sparkles_on_char(10,170,1,3);
			damage_char(10,1000 + get_ran(1,0,200),2);
			}
		else if (cutscene == 9) {
			cutscene = 10;
			}
		else if (cutscene == 10) {
			cutscene = 12;
			}
		else if (cutscene == 12) {
			cutscene = 13;
			begin_talk_mode(24);
			}
		else if (cutscene == 13) {
			give_char_text_bubble(8,"Waste of time.");
			give_char_text_bubble(9,"Going back where it's warm.");
			move_to_loc(8,3,21);
			move_to_loc(9,39,59);
			cutscene = 14;
			}
		else if (cutscene == 14) {
				sf(1,7,4);
				cutscene = 30;

				
				toggle_cutscene(0);
				shift_view_to_char(pc_num());
				
			}
		}
	if (gf(1,7) == 4) {
		if (char_ok(8)) {
			move_to_loc(8,3,21);
			if (dist_to_nav_point(8,3) <= 3)
				erase_char(8);
			}
		if (char_ok(9)) {
			move_to_loc(9,39,59);
			if (dist_to_nav_point(9,2) <= 3)
				erase_char(9);
			}
		if (char_ok(10)) {
			move_to_loc(10,39,59);
			if (dist_to_nav_point(10,2) <= 3)
				erase_char(10);
			}
		}
break;

beginstate 10;
	if (gf(1,7) == 0) {
		cutscene = 1;
		sf(1,7,1);
		char_clear_action(1000);
		toggle_cutscene(1);
		}
break;

beginstate 11;
	set_terrain_string_range("The sign says - Evaluation Halls. All Non-Chosen Types Judged Here.",3);
break;

beginstate 12;
	if ((gf(1,9) == 0) && (char_ok(11)) && (get_attitude(11) < 10)) {
		sf(1,9,1);
		begin_talk_mode(40);
		}
break;
		

//	print_str("");
//	set_terrain_string_range(".",3);
//	set_terrain_string_range("The sign says - .",3);
